package com.lft.freshordering.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lft.freshordering.entity.Gocar;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GocarMapper extends BaseMapper<Gocar> {
    //新增购物车
    @Insert("INSERT \n" +
            "INTO gocar(uid,sid,count)VALUES(#{uid},#{sid},#{count})")
    int insertGocar(Gocar gocar);

    //根据用户id和商品id 查询购物车中的商品
    @Select("SELECT * \n" +
            "from gocar\n" +
            "where uid = #{uid} and  sid = #{sid}")
    Gocar selectGocar(Integer uid, Integer sid);

    //修改购物车中商品的数量
    int updateGocar(Gocar gocar);

    //根据用户id查询购物车信息
    @Select("SELECT * \n" +
            "from gocar\n" +
            "where uid = #{uid} ")
    List<Gocar> selectbyuid(Integer uid);


}
